#pragma once

#include <vector>
#include "maya/MItMeshEdge.h"
#include "maya/MItMeshVertex.h"
#include "maya/MItMeshPolygon.h"
#include "maya/MIntArray.h"
#include "maya/MVector.h"
#include "EdgeBase.h"
#include "VertexBase.h"
#include <vector>

using namespace std;
class AngleSpace
{
public:
	AngleSpace(MItMeshEdge* edgeIt, MItMeshPolygon* faceIt, MItMeshVertex* vertsIt, vector<int> seamVerts, vector<int> seamEdges);
	~AngleSpace(void);

	//vector form
	void updateAngles(const vector<double>);
	//MUST BE DELETED AFTER USE
	vector<double>* getAngles();

	//objective
	double angularDistortion();
	void calcGradObjective(vector<double> &grad);
	void calcGradTriangle(vector<double> &grad);
	void calcGradPlanar(vector<double> &grad);
	void calcGradReconstruction(vector<double> &grad);

	//constraints
	double triangleValidity();
	double planarValidity();
	double wheelValidity();

	//utility
	VertexBase* getCorner(int index);
	void printAngleSpace();

	//Get Edge Map
	map<int,EdgeBase*> getEdgeMap();
	map<int,VertexBase*> getVertexMap();
	map<int,TriangleBase*> getTriangleMap();

private:
	struct Triangle {MPoint a; MPoint b; MPoint c;};
	map<int,TriangleBase*> triangles;
	map<int,VertexBase*> vertices;
	map<int,EdgeBase*> edges;
	
};

